/**
 * https://leetcode-cn.com/problems/corporate-flight-bookings/submissions/
 * @param {number[][]} bookings
 * @param {number} n
 * @return {number[]}
 */
 var corpFlightBookings = function(bookings, n) {
    const gaps = (new Array(n + 1)).fill(0);
    bookings.forEach(([start, end, num]) => {
        gaps[start] += num;
        if (end < gaps.length - 1) {
            gaps[end + 1] -= num;
        }
    })
    const answer = (new Array(n + 1)).fill(0);
    for (let i = 0; i < gaps.length; i++) {
        if (i === 0) {
            continue;
        }
        answer[i] = answer[i - 1] + gaps[i];
    }
    answer.shift();
    return answer;
};